package com.cupcorn.lib.game;

import org.andengine.entity.primitive.Rectangle;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.cupcorn.lib.Anchor;
import com.cupcorn.lib.Ratio;
import com.cupcorn.lib.Utils;

public class GameRectangle extends Rectangle
{
	public GameText	text;
	
	public GameRectangle(float pX, float pY, float pWidth, float pHeight, VertexBufferObjectManager pVertexBufferObjectManager)
	{
		super(pX, pY, pWidth, pHeight, pVertexBufferObjectManager);
	}
	
	public void setPosition(float pX, float pY, Anchor anchor, Ratio ratio)
	{
		super.setPosition(Utils.getPosX(pX, this.mWidth, anchor, ratio), Utils.getPosY(pY, mHeight, anchor, ratio));
	}
	
	public void addText(GameText text)
	{
		this.text = text;
		text.setPosition(Utils.getCenter(mWidth, text.getWidthScaled()), Utils.getCenter(mHeight, text.getHeightScaled()));
		attachChild(text);
	}
}
